//
//  YQSettingViewClass.m
//  NewRetail
//
//  Created by yuqin on 2019/6/30.
//  Copyright © 2019 yuqin. All rights reserved.
//

#import "YQSettingViewClass.h"
#import "YQAboutUsHeadView.h"
#import "YQWalletDetailCell.h"

@interface YQSettingViewClass ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) YQAboutUsHeadView *aboutHeadView;
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *theTitleArray;
@end

@implementation YQSettingViewClass

- (void)viewDidLoad {
    [super viewDidLoad];
    self.txtTitle.text = self.theTitle;
    //区分当前进入的是系统设置 、帮助中心、关于我们
    [self setupClassView];
}

- (void)setupClassView {
    [self.view addSubview:self.tableView];
    if ([self.theTitle isEqualToString:@"系统设置"]) {
        self.theTitleArray = @[@"多语言",@"数值样式",@"安全登录"];
        [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(0);
            make.top.equalTo(self.headView.mas_bottom).mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(ScreenWidth, TableView_Height_IPhoneX));
        }];
    }else if ([self.theTitle isEqualToString:@"帮助中心"]) {
        self.theTitleArray = @[@"常见问题",@"联系我们",@"意见反馈"];
        [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(0);
            make.top.equalTo(self.headView.mas_bottom).mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(ScreenWidth, TableView_Height_IPhoneX));
        }];
    }else {
        self.theTitleArray = @[@"常见问题",@"联系我们",@"意见反馈"];
        [self.view addSubview:self.aboutHeadView];
        [self.aboutHeadView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(0);
            make.top.equalTo(self.headView.mas_bottom).mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(ScreenWidth, self.aboutHeadView.headViewHeight));
        }];
        
        [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(0);
            make.top.equalTo(self.aboutHeadView.mas_bottom).mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(ScreenWidth, TableView_Height_IPhoneX-self.aboutHeadView.headViewHeight));
        }];
    }
}

- (YQAboutUsHeadView *)aboutHeadView {
    if (!_aboutHeadView) {
        _aboutHeadView = [[YQAboutUsHeadView alloc] init];
    }
    return _aboutHeadView;
}

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.backgroundColor = LineColor;
        _tableView.delegate = self;
        _tableView.dataSource =self;
        _tableView.tableFooterView = [[UIView alloc] init];
        [_tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
        [_tableView registerNib:[UINib nibWithNibName:YQ_WalletDetailCell bundle:nil] forCellReuseIdentifier:YQ_WalletDetailCell];
    }
    return _tableView;
}

#pragma mark - 代理

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.theTitleArray.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return FIT(55);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    YQWalletDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:YQ_WalletDetailCell forIndexPath:indexPath];
    cell.theTitleLab.text = self.theTitleArray[indexPath.row];
    if (indexPath.row == 2) {
        [cell.bottomLineView setHidden:YES];
    }
    if ([self.theTitle isEqualToString:@"系统设置"]) {
        NSArray *arr = @[@"简体中文",@"24，25512",@"关"];
        cell.describeLab.text = arr[indexPath.row];
        if (indexPath.row == 2) {
            cell.describeLab.textColor = MainRedTextColor;
        }
    }else if ([self.theTitle isEqualToString:@"帮助中心"]) {
        
    }else {
        
    }
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end
